package com.youhome.service.service.impl;

import com.youhome.common.exception.CustomException;
import com.youhome.service.mapper.HouseInfoMapper;
import com.youhome.service.mapper.ListHubMapper;
import com.youhome.service.model.HouseInfo;
import com.youhome.service.model.ListHubParam;
import com.youhome.service.service.HouseInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

/**
 * Created by chen365 on 2017/9/11.
 */
@Service
public class HouseInfoServiceImpl implements HouseInfoService {
    @Autowired
    private HouseInfoMapper houseInfoMapper;
    @Autowired
    private ListHubMapper listHubMapper;

    @Override
    @Cacheable(value = "house_info", key = "'house_info'")
    public HouseInfo selectHouseInfo() throws CustomException {
        HouseInfo houseInfo = houseInfoMapper.selectOneByOrderByUpdatedDesc();
        ListHubParam param = new ListHubParam();
        int count = listHubMapper.selectCountByBean(param);
        houseInfo.setHouseCount(count);
        return houseInfo;
    }
}
